package com.tom.service.impl;

import com.tom.mapper.FoodMapper;
import com.tom.pojo.Food;
import com.tom.service.IFoodService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service("foodService")
public class FoodServiceImpl implements IFoodService {
    @Resource
    private FoodMapper foodMapper;

    @Override
    public List<Food> listFood(Integer restId) {
        return foodMapper.selectByRestaurantId(restId);
    }

    @Override
    public List<Food> searchFood(Food food) {
        return foodMapper.selectByFood(food);
    }

    @Override
    public int newFood(Food food) {
        return foodMapper.insertSelective(food);
    }

    @Override
    public int updateFood(Food food) {
        return foodMapper.updateByPrimaryKeySelective(food);
    }

    @Override
    public int removeFood(Integer id) {
        return foodMapper.deleteByPrimaryKey(id);
    }
}
